
import ac = module("utils/commons/array-collection");

	
/**
	* Lists the possible formats that an attribute value can take when it is 
	* assigned as a data type for the attribute. The semantic 
	* meaning of the data types in the enumeration are defined with the 
	* structure in which they are used (e.g. Concept Scheme).
	* 
	* @author Xavier Sosnovsky, Anthony Morel
	*/
export class FacetType {
		
	/*==============================Fields================================*/
		
	private static _instance:FacetType;
		
	private static _facetTypes:ac.ArrayCollection<string>;
		
	/*============================Constants===============================*/
		
	/**
	    * If true, the Representation is an incremental sequence of integer 
	    * values (value range) or date/time values (time range). The facets 
	    * startValue, and interval or timeInterval must also be specified for a 
	    * sequence.
	    */
	public static IS_SEQUENCE:string = "isSequence";
		
	/**
	    * If true, valid values for the Representation lie within the given
	    * value/time range, otherwise outside the value/time range.
	    */
	public static IS_INCLUSIVE:string = "isInclusive";
		
	/**
	    * Specifies the minimum number of characters for a value.
	    */
	public static MIN_LENGTH:string = "minLength";
		
	/**
	    * Specifies the maximum number of characters for a value.
	    */
	public static MAX_LENGTH:string = "maxLength";
		
	/**
	    * Specifies the minimum numeric value.
	    */
	public static MIN_VALUE:string = "minValue";
		
	/**
	    * Specifies the maximum numeric value.
	    */
	public static MAX_VALUE:string = "maxValue";
		
	/**
	    * Specifies the starting value for a sequence (time or value range).
	    */
	public static START_VALUE:string = "startValue";
		
	/**
	    * Specifies the end value for a sequence (time or value range).
	    */
	public static END_VALUE:string = "endValue";
		
	/**
	    * Used to specify the incremental steps of a value range. Starting from
	    * startValue, and incrementing by increment until endValue is reached. 
	    * The sequence then begins again from startValue. If no endValue is 
	    * specified, the sequence continues indefinitely.
	    */
	public static INCREMENT:string = "increment";
		
	/**
	    * Used to specify the incremental steps (periods) of a time range. 
	    * Starting from startValue, and incrementing by timeInterval until 
	    * endValue is reached. The sequence then begins again from startValue. 
	    * If no endValue is specified, the sequence continues indefinitely.
	    */
	public static TIME_INTERVAL:string = "timeInterval";
		
	/**
	    * The Representation has a specified number of decimals.
	    */
	public static DECIMALS:string = "decimals";
		
	/**
	    * The Representation is a regular expression (see XSD spec) which is
	    * expressed as a string.
	    */
	public static PATTERN:string = "pattern";
		
	/**
	    * The Representation is an enumeration of Items in specific scheme of
	    * Items, such as an identified {@link CodeList}.
	    */
	public static ENUMERATION:string = "enumeration";
		
	/*===========================Constructor==============================*/
		
	constructor(enforcer:SingletonEnforcer) {
	}
		
	/*==========================Public methods============================*/
		
	/**
		* Whether the supplied facet type is in the list of valid facet types. 
		* 
		* @param facetType The supplied facet type.
		* 
		* @return true if the supplied facet type is in the list of valid SDMX 
	    * facet types, false otherwise.
		*/
	public static contains(facetType:string):bool {
	    return this.createFacetTypesList().contains(facetType);
	}
	    
	/*=========================Private methods============================*/
	    
	private static createFacetTypesList():ac.ArrayCollection<string> {
	    if (null == this._instance) {
	    	this._instance = new FacetType(new SingletonEnforcer());
		    this._facetTypes = new ac.ArrayCollection<string>();
		    this._facetTypes.addItem(FacetType.IS_SEQUENCE);	    	
		    this._facetTypes.addItem(FacetType.IS_INCLUSIVE);
		    this._facetTypes.addItem(FacetType.MIN_LENGTH);
		    this._facetTypes.addItem(FacetType.MAX_LENGTH);
		    this._facetTypes.addItem(FacetType.MAX_VALUE);
		    this._facetTypes.addItem(FacetType.MAX_VALUE);
		    this._facetTypes.addItem(FacetType.START_VALUE);
		    this._facetTypes.addItem(FacetType.END_VALUE);
		    this._facetTypes.addItem(FacetType.INCREMENT);
		    this._facetTypes.addItem(FacetType.TIME_INTERVAL);
		    this._facetTypes.addItem(FacetType.DECIMALS);
		    this._facetTypes.addItem(FacetType.PATTERN);
		    this._facetTypes.addItem(FacetType.ENUMERATION);
		}
		return this._facetTypes;
	}
}

export class SingletonEnforcer {
}